from django.db import models

# Create your models here.

class URLMapping(models.Model):
    id = models.AutoField(primary_key=True)
    # 相同施工的归类ID一样，可以更新最新告警的经纬度信息，更新长链接
    merge_id = models.CharField(max_length=255, null=True, blank=True,db_index=True,verbose_name="告警归类的id")
    long_url = models.CharField(max_length=512,verbose_name='长链接')
    short_code = models.CharField(max_length=64, unique=True,db_index=True,null=True)
    soure_code_len = models.SmallIntegerField(verbose_name='记录short_code的原始长度',default=0)
    count = models.IntegerField(default=0,verbose_name='短链接访问次数')
    create_time = models.DateTimeField(null=True,auto_now_add=True,verbose_name='创建时间')
    class Meta:
        db_table='url_mapping'

class AccessToken(models.Model):
    id = models.AutoField(primary_key=True)
    token = models.CharField(max_length=256,db_index=True,verbose_name='token')
    create_time = models.DateTimeField(auto_now_add=True,verbose_name='创建时间')
    exp_time = models.DateTimeField(null=True,verbose_name='过期时间')
    class Meta:
        db_table = 'access_token'
